package com.huaboot.commont.core;

import com.huaboot.commont.exception.ErrorCode;
import lombok.Data;

import java.io.Serializable;

/**
 * @author ff
 * @ClassName BaseResponse
 * @description: 通用返回
 * @date 2023年08月09日
 */
@Data
public class BaseResponse<T> implements Serializable {

    private int code;

    private T data;

    private String msg;

    public BaseResponse(int code, T data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    public BaseResponse(int code, T data) {
        this(code, data, "");
    }

    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(), null, errorCode.getMessage()
        );
    }
}
